<template>
  <div class="dividend-pool">
    <div class="dividend-content">
      <div class="dividend-info">
        <div>
          <h3 class="dividend-title">当前分红池</h3>
          <p class="dividend-amount">{{ amount }} {{ currency }}</p>
          <p class="dividend-estimate">现在参与预计可得: <span>{{ estimate }} {{ currency }}</span></p>
        </div>
        <div class="dividend-history">
          <p class="dividend-label">上次分红</p>
          <p class="dividend-value">{{ yesterdayDividend }} {{ currency }}/人</p>
        </div>
      </div>
      <div class="button-group">
        <van-button 
          block
          type="primary"
          class="dividend-button"
          @click="onClick"
        >
          立即参与
        </van-button>
        <van-button 
          block
          type="default"
          class="ranking-button"
          @click="goToRanking"
        >
          查看排行榜
        </van-button>
      </div>
    </div>
  </div>
</template>

<script setup>
defineProps({
  amount: {
    type: String,
    default: '0'
  },
  estimate: {
    type: String,
    default: '0'
  },
  yesterdayDividend: {
    type: String,
    default: '0'
  },
  currency: {
    type: String,
    default: 'U'
  }
})

import { useRouter } from 'vue-router'

const router = useRouter()
const emit = defineEmits(['click'])

const onClick = () => {
  emit('click')
}

const goToRanking = () => {
  router.push('rank')
}
</script>

<style scoped>
.dividend-pool {
  margin: -20px 16px 0;
  position: relative;
  z-index: 10;
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--box-shadow);
}

.dividend-content {
  background: linear-gradient(135deg, var(--primary-color), #0960c5);
  padding: 20px;
  color: white;
}

.dividend-info {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.dividend-title {
  font-size: 16px;
  font-weight: 500;
  opacity: 0.9;
  margin: 0 0 8px;
}

.dividend-amount {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px;
}

.dividend-estimate {
  font-size: 14px;
  opacity: 0.9;
  margin: 0;
}

.dividend-estimate span {
  font-weight: 600;
}

.dividend-history {
  text-align: right;
}

.dividend-label {
  font-size: 14px;
  opacity: 0.9;
  margin: 0 0 4px;
}

.dividend-value {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.button-group {
  margin-top: 16px;
  display: flex;
  gap: 10px;
}

.dividend-button {
  background-color: white !important;
  color: var(--primary-color) !important;
  border: none !important;
  font-weight: 500;
  flex: 1;
}

.ranking-button {
  background-color: rgba(255, 255, 255, 0.2) !important;
  color: white !important;
  border: 1px solid rgba(255, 255, 255, 0.5) !important;
  font-weight: 500;
  flex: 1;
}
</style>